Skip to content

Conversation

@wenyongh
Copy link
Contributor

Refactor LLVM JIT for some purposes:

The changes mainly includes:

  • Remove the MCJIT mode, replaced it with ORC JIT eager mode
  • Remove the LLVM legacy pass manager (only keep the LLVM new pass manager)
  • Changed the lazy mode's LLVM module/function binding:
    change each function in an individual LLVM module into all functions in a single LLVM module
  • Upgraded ORC JIT to ORCv2 JIT to enable lazy compilation

Refer to #1468

wenyongh and others added 10 commits September 1, 2022 07:42
Merge main into dev/refactor_llvm_jit
Re-organize LLVM JIT mode implementation, includes:
- Remove code with MCJIT APIs. Embrance ORC.
  - WASM_ENABLE_LAZY_JIT only represent lazy compilation. It won't specify
    ORC or MCJIT
  - Remove runtime ORC compilation threads and move all aot functions
    into one module
  - Current LLVM ORC JIT implements eagel compilation. Will add lazy
    compilation later
- JIT and AOT both apply the new pass manager
  - All JIT passes are in IRTransferLayer

P.S.
| Varient impl.           | Norm. Score | Norm. (ms) |
| ----------------------- | ----------- | ---------- |
| Original                | 1.0         | 1.0        |
| Apply the new PM        | 1.01        | 1.007      |
| Opt in IRTransformLayer | 0.997       | 1.04       |

* Performance Tuning

1. Register the `AAManager` and `buildDefaultAAPipeline`
2. Use function pointers in `aot_compile_op_call` and `aot_compile_op_indirect_call`
   instead of `lookup_orcjit_func`

CoreMark Score:
| Varient impl.           | Norm. Score | Norm. (ms) |
| ----------------------- | ----------- | ---------- |
| Original                | 1.0         | 1.0        |
| Apply the new PM        | 1.01        | 1.007      |
| Opt in IRTransformLayer | 0.997       | 1.04       |
| Tuning#1                | 1.01        | 0.83       |

* fix assertions about function pointers
Merge main into dev/refactor_llvm_jit
Merge main into dev/refactor_llvm_jit
Use LLJIT to do eager compilation
Use LLLazyJIT to do lazy compilation
Merge main into dev/refactor_llvm_jit
Remove looking up jit func addresses with backend threads

Compile several functions as a group for the orcjit compile threads, which
shows that it can reduce the compilation time

Add WASM_ORC_JIT_BACKEND_THREAD_NUM to distinguish it form
WASM_ORC_JIT_COMPILE_THREAD_NUM

Move orcjit thread args/handles global variables into aot module

Test apply llvm new pass manager in do_ir_transform callback of
LLVMOrcIRTransformLayerSetTransform

Fix build error for LLVM 15.0
@wenyongh wenyongh merged commit e87a554 into main Oct 18, 2022
@wenyongh wenyongh deleted the dev/refactor_llvm_jit branch October 27, 2022 04:25
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Refactor LLVM JIT for some purposes:
- To simplify the source code of JIT compilation
- To simplify the JIT modes
- To align with LLVM latest changes
- To prepare for the Multi-tier JIT compilation, refer to bytecodealliance#1302

The changes mainly include:
- Remove the MCJIT mode, replace it with ORC JIT eager mode
- Remove the LLVM legacy pass manager (only keep the LLVM new pass manager)
- Change the lazy mode's LLVM module/function binding:
  change each function in an individual LLVM module into all functions in a single LLVM module
- Upgraded ORC JIT to ORCv2 JIT to enable lazy compilation

Refer to bytecodealliance#1468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants